//Sliver List Ite
import 'package:flutter/material.dart';

import '../extensions/hex_color.dart';
import 'yq_progress.dart';

class PublicWelfareCard extends StatelessWidget {
  final String imageUrl;
  final String title;
  final double progress;
  final String progressText;
  final String target;
  final VoidCallback onTap;

  const PublicWelfareCard({
    super.key,
    required this.imageUrl,
    required this.title,
    required this.progress,
    required this.progressText,
    required this.target,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        height: 200,
        margin: const EdgeInsets.only(bottom: 16),
        child: Stack(
          children: [
            // 背景图
            ClipRRect(
              borderRadius: BorderRadius.circular(12),
              child: Image.asset(
                imageUrl,
                width: double.infinity,
                height: double.infinity,
                fit: BoxFit.cover,
              ),
            ),
            // 内容卡片
            Positioned(
              left: 12,
              right: 12,
              bottom: 12,
              child: RaiseProgressCard(
                  title: title,
                  progress: progress,
                  progressText: progressText,
                  target: target),
            ),
          ],
        ),
      ),
    );
  }
}

class RaiseProgressCard extends StatelessWidget {
  const RaiseProgressCard({
    super.key,
    required this.title,
    required this.progress,
    required this.progressText,
    required this.target,
  });

  final String title;
  final double progress;
  final String progressText;
  final String target;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(
            title,
            style: const TextStyle(
              fontSize: 18,
              fontWeight: FontWeight.bold,
            ),
          ),
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    ProgressWidget(
                      progress: progress,
                      progressText: progressText,
                      target: target,
                      gradientColors: [
                        HexColor.fromHexWithoutAlpha("#08C164"),
                        HexColor.fromHexWithoutAlpha("#08C164"),
                      ],
                    ),
                    ProgressInfo(
                      progressText: progressText,
                      target: target,
                      raiseStatusTitleFontSize: 12,
                      raiseTargetTitleFontSize: 12,
                    ),
                  ],
                ),
              ),
              const SizedBox(width: 16),
              Column(
                children: [
                  InkWell(
                      child: Container(
                        decoration: BoxDecoration(
                          color: Colors.green,
                          borderRadius: BorderRadius.circular(20),
                        ),
                        margin: const EdgeInsets.only(bottom: 20),
                        padding: const EdgeInsets.symmetric(
                            horizontal: 25, vertical: 8),
                        child: const Text(
                          '捐赠',
                          style: TextStyle(color: Colors.white, fontSize: 15),
                        ),
                      ),
                      onTap: () {
                        // 处理捐赠按钮点击
                      }),
                  const SizedBox(
                    height: 10,
                  )
                ],
              ),
            ],
          ),
        ],
      ),
    );
  }
}
